#ifndef PRAC62_H_
#define PRAC62_H_

//******************************************************************************
// EDROOM Service Library

#define _EDROOM_IS_DEBUG_

#define _EDROOM_IS_EMBEDDED_

#include <public/edroomsl_iface_v1.h>

/**
 * \class   prac62
 *
 */
class prac62: public CEDROOMComponent {

public:

	/**
	 * \enum EDROOMprac62Signal
	 * \brief Component Signal Enum Type
	 *
	 */
	 enum EDROOMprac62Signal { EDROOMSignalTimeout, 
							EDROOMSignalDestroy };

	/**
	 * \class prac62::CEDROOMMemory
	 * \brief Component Memory
	 *
	 */
	class CEDROOMMemory: public CEDROOMComponentMemory{

		private:

			//!Array of Message Queue Heads, one for each priority
			CEDROOMQueue::CQueueHead QueueHeads[EDROOMprioMINIMUM+1];

			public:



			/** \brief This function is used for setting the Component Memory
			 * 
			 * \param numberOfMsgs number of messages that the component can store
			 * \param msgsMemory memory for the messages that the component can store
			 * \param msgsMemory memory marks for the messages that the component can store
			 * \param queueNodesMemory memory for the component message queues 
			 * \param queueNodesMemoryMarks memory marks for the component message queues 
			 */
			void SetMemory(TEDROOMUInt32 numberOfMsgs
						, CEDROOMMessage * msgsMemory
						, TEDROOMBool * msgsMemoryMarks
						, CEDROOMQueue::CQueueNode * queueNodesMemory
						, TEDROOMBool * queueNodesMemoryMarks);

	};


	// ********************************************************************
	//******************  Component Communication Ports *******************
	// ********************************************************************





	// *************************************************************************
	// **************************** Frame Service Methods	********************
	// *************************************************************************



	//! Constructor
	prac62(const char * const roomname, TEDROOMComponentID id, TEDROOMUInt32 roomNumMaxMens, TEDROOMPriority roomtaskPrio, TEDROOMStackSizeType roomStack, CEDROOMMemory * pActorMemory );




	//! Component Configuration 
	 int EDROOMConfig();


	//! Component Start 
	 int EDROOMStart();




	#ifdef _EDROOM_SYSTEM_CLOSE

	//! Method that returns true if component is finished 
	TEDROOMBool EDROOMIsComponentFinished();


	#endif

protected:



	//! Component behaviour 
	virtual void EDROOMBehaviour();




public:

	// *****************************	Behaviour  *************************

	// ***********************************************************************

	// class EDROOMTopContext

	// ***********************************************************************



	class EDROOMTopContext {

	protected:

	enum EDROOMprac62Signal { EDROOMSignalTimeout, EDROOMSignalDestroy };


		friend class prac62;

		prac62 &EDROOMcomponent;

		CEDROOMMessage * &Msg;

		CEDROOMMessage * &MsgBack;

		//Ports


			enum edroomStateId{I};

			enum IdTrans{ EDROOMMEMORIA };

		//Constantes



		//Variables



		//Pool



		// CONSTRUCTORES

		EDROOMTopContext (prac62 &act );

		EDROOMTopContext ( EDROOMTopContext &contex );

	public:

		bool EDROOMSearchContextTrans(TEDROOMTransId &edroomCurrentTrans);

		void EDROOMNuevoMens () { EDROOMcomponent.EDROOMNewMsg(); }

	};

	// ***********************************************************************

	// class EDROOMTopState

	// ***********************************************************************



	class EDROOMTopState : public EDROOMTopContext {

	protected:



		EDROOMTopContext::edroomStateId edroomCurrentState;

		EDROOMTopContext::edroomStateId edroomNextState;

		//Variables



		//Pools



	public:

		// CONSTRUCTOR

		EDROOMTopState (prac62 &act );


		// EDROOMBehaviour**********************************************

		void EDROOMBehaviour();

		// Inicio**********************************************

		void EDROOMInicio();

		// ***********************************************************************

		// SubEstado Inicial 

		// ***********************************************************************



		TEDROOMTransId EDROOMIllegada();

	};

protected:

	// ********************************  Top State  ****************************

	EDROOMTopState edroomTopState;



};
#endif
